<!DOCTYPE html>
<html>
<head>
    <title>平涛</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">

<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/weui.min.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/jquery-weui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/style.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wechat/css/aui-iconfont.css">

    <style type="text/css">
        .weui_panel:after{border-bottom: none !important;  }
        .input_con{width: 88% !important;}
        .weui_cell_bd{margin:5px;}
        input{border: none}
        a{color: red}
        .weui_cell{padding: 0px !important;}
        input,textarea{background: #FAFAFA}
        .weui_cell:before{border-top: none !important;}
        .weui_navbar_item{padding: 17px 11px !important}

    </style>

</head>


<body ontouchstart>
    <form>
    <div class="weui_tab">
        <div class="weui_navbar weui_navbar1">
            <div class="weui_navbar_item weui_bar_item_on">
                <div style="text-align:left;float:left">
                    <a href="{:U('Work/index')}">
                        <span class="aui-iconfont aui-icon-left"></span>
                    </a>
                </div>
                <span>工作总结</span>
                <div class="f-r">
                    <span class="f-s1" id="sub" style="cursor:pointer;color:green;" onclick="tj()">修改</span>
                </div>
            </div>
        </div>

        <div class="weui_tab_bd">
            <div class="zj">
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="time2" class="weui_label">总结日期：</label></div>
                    <div class="weui_cell_bd weui_cell_primary">{$workArr.date}</div>
                </div>
            </div>

            <div class="zj m-t1">
                <div class="weui_cell">
                    <div class="weui_cell_hd"><label for="" class="weui_label">总结内容：</label></div>
                </div>
                <div class="weui_cell l-h2 input_box">
                    <div class="weui_cell_bd weui_cell_primary">
                        <textarea class="weui_textarea" id="content" name="content" rows="5" placeholder="请输入内容">{$workArr.content}</textarea>
                    </div>
                </div>
            </div>

        </div>

        <include file="Index/footer" />

    </div>
    </form>

    <script type="text/javascript" src="__PUBLIC__/Wechat/js/jquery-2.1.4.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/js/fastclick.js"></script>
    <!-- <script type="text/javascript" src="__PUBLIC__/Wechat/js/autosize.js"></script> -->
    <script type="text/javascript" src="__PUBLIC__/Wechat/js/jquery-weui.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Wechat/layer_mobile/layer.js"></script>
    <script>
        $(function() {
            FastClick.attach(document.body);
        });

        // autosize(document.querySelectorAll('textarea'));

        // 添加新行
        // function add(){
        //     var len = $('.input_box').length + 1;
        //     var content = '<div class="weui_cell l-h2 input_box"><div class="weui_cell_hd"><label for="" class="weui_label lab1">' + len + '.</label></div><div class="weui_cell_bd weui_cell_primary"><textarea class="weui_textarea textarea_1" name="content' + len + '" placeholder="请输入内容" rows="1"></textarea></div></div>';
        //     $('.input_box:last').after(content);
        //     $('#num').val(len);
        // }

        // 保存
        function tj(){
            //$('form').submit();
            if( $.trim($('#content').val()) ){
                $('#sub').attr('onclick','');  // 避免重复提交
                $.ajax({
                    url: "{:U('Work/editCheck',array('id'=>$workArr['id']))}",
                    type: "POST",
                    data: $('form').serializeArray(),
                    success: function(msg){
                        //console.log(msg);
                        layer.open({
                            content: msg['content'],
                            skin: 'msg',
                            time: 1 ,
                        });
                        if(msg['state'] == 200){
                            setTimeout('window.location.href = "{:U('Work/index')}"', 1000);
                        }else{
                            $('#sub').attr('onclick','tj()');  // 添加出错，允许重新提交
                        }
                    }
                });
            }else{
                layer.open({
                    content: '请填写总结内容',
                    skin: 'msg',
                    time: 1 ,
                });
            }

        }
    </script>


</body>
</html>
